package com.hanthink.web.controller.manhour;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.system.domain.manhour.PLineEquipment;
import com.hanthink.system.service.manhour.IPLineEquipmentService;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 生产线基础数据Controller
 * 
 * @author hanthink
 * @date 2022-05-05
 */
@RestController
@RequestMapping("/manhour/PLineEquipment")
public class PLineEquipmentController extends BaseController
{
    @Autowired
    private IPLineEquipmentService pLineEquipmentService;

    /**
     * 查询生产线基础数据列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(PLineEquipment pLineEquipment)
    {
        startPage();
        List<PLineEquipment> list = pLineEquipmentService.selectPLineEquipmentList(pLineEquipment);
        return getDataTable(list);
    }

    /**
     * 导出生产线基础数据列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:export')")
    @Log(title = "生产线基础数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PLineEquipment pLineEquipment)
    {
        List<PLineEquipment> list = pLineEquipmentService.selectPLineEquipmentList(pLineEquipment);
        ExcelUtil<PLineEquipment> util = new ExcelUtil<PLineEquipment>(PLineEquipment.class);
        return util.exportExcel(list, "PLineEquipment");
    }

    /**
     * 获取生产线基础数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:query')")
    @GetMapping(value = "/{plineid}")
    public AjaxResult getInfo(@PathVariable("plineid") String plineid)
    {
        return AjaxResult.success(pLineEquipmentService.selectPLineEquipmentById(plineid));
    }

    /**
     * 新增生产线基础数据
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:add')")
    @Log(title = "生产线基础数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PLineEquipment pLineEquipment)
    {
        return toAjax(pLineEquipmentService.insertPLineEquipment(pLineEquipment));
    }

    /**
     * 修改生产线基础数据
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:edit')")
    @Log(title = "生产线基础数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PLineEquipment pLineEquipment)
    {
        return toAjax(pLineEquipmentService.updatePLineEquipment(pLineEquipment));
    }

    /**
     * 删除生产线基础数据
     */
    @PreAuthorize("@ss.hasPermi('manhour:PLineEquipment:remove')")
    @Log(title = "生产线基础数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{plineids}")
    public AjaxResult remove(@PathVariable String[] plineids)
    {
        return toAjax(pLineEquipmentService.deletePLineEquipmentByIds(plineids));
    }
}
